home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 2.iso
/
BARNET
/
COMPILER
/
SATHER
/
!Sather
/
Library
/
Containrs
/
sa
/
bag
< prev
next >
Wrap
Text File
|
1996-04-09
|
3KB
|
71 lines
---------------------------> Sather 1.1 source file <--------------------------
-- Copyright (C) 1995, International Computer Science Institute
-- COPYRIGHT NOTICE: This code is provided WITHOUT ANY WARRANTY
-- and is subject to the terms of the SATHER LIBRARY GENERAL PUBLIC
-- LICENSE contained in the file: Sather/Doc/License of the
-- Sather distribution. The license is also available from ICSI,
-- 1947 Center St., Suite 600, Berkeley CA 94704, USA.
--=============================================================================
-- Author: Holger Klawitter
-- Benedict Gomes: Extensively modified include structure, naming
-- added partial class, changed subtyping
-- $RO_BAG{E} : Read-only bag
-- $BAG{E} : Bag abstraction
-- BAG_INCL{E} : Partial class for use with concrete bags
-- H_BAG{E} : Bag based on the DYNAMIC_DATA_BUCKET kernel
-- BAG{E} : Standard bag class
-- $Id: bag.sa,v 1.5 1996/04/09 10:04:46 borisv Exp $
--===========================================================================
abstract class $RO_BAG{E} < $CONTAINER{E}, $STR is
-- A Bag contains objects in no specified order. A Bag can
-- contain two equal objects.
count(e:E): INT;
-- Returns the number of occurences of 'e' in the bag.
unique!: E;
-- Yields all element from the bag, but every element will be
-- yielded not more than once.
n_unique: INT;
-- Returns the numver of different(!) elements in the bag.
union(b: $RO_BAG{E}): $BAG{E};
-- The union contains the elements of "self" and "b".
-- result.count(e) = self.count(e) + b.count(e)
-- Is this a good definition? Is not symmetric with intersection
-- STL uses maximum rather than arithmetic sum
intersection(b: $RO_BAG{E}):$BAG{E};
-- result.count(e) = minimum_of(self.count(e),b.count(e))
is_subset(b: $RO_BAG{E}): BOOL;
equals(b: $RO_BAG{E}): BOOL;
-- Return true if self and "b" have the same elements in the
-- same quantities
end;
--==========================================================================
abstract class $BAG{E} < $RO_BAG{E} is
-- A standard bag, which contains objects in no specified order,
-- and can contain two equal objects
insert(e:E);
-- Puts the element into the bag.
delete(e:E);
-- Remove one occurence of the element from the bag. Does
-- nothing, if there is no such element in to bag.
delete_all(e:E);
-- Remove all occurences of the element 'e'.
delete_all(e:E): INT;
-- Returns the number of deleted items.
end; -- $BAG{E}
--===========================================================================